package com.owen.user.dao;

import java.util.List;
import java.util.Map;

import com.owen.common.model.SysRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
* @author 作者 owen E-mail: 624191343@qq.com
* @version 创建时间：2017年11月12日 上午22:57:51
 * 角色
 */
@Mapper
public interface SysRoleDao {

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into t_user_role(code, name, createTime, updateTime) values(#{code}, #{name}, #{createTime}, #{createTime})")
    int save(SysRole sysRole);

    @Update("update t_user_role t set t.name = #{name} ,t.updateTime = #{updateTime} where t.id = #{id}")
    int updateByOps(SysRole sysRole);

    @Select("select * from t_user_role t where t.id = #{id}")
    SysRole findById(Long id);

    @Select("select * from t_user_role t where t.code = #{code}")
    SysRole findByCode(String code);

    @Delete("delete from t_user_role where id = #{id}")
    int delete(Long id);

    int count(Map<String, Object> params);

    List<SysRole> findList(Map<String, Object> params);

}
